Prolog, Mercury and the termination problem

نویسنده

  • Anna Sasak
چکیده

This paper shortly introduces the two logic programming languages Prolog and Mercury. On this background we introduce the problem of analysing termination of programs. Then we present Mercury’s termination analyser, that the authors of the language incorporated into its compiler. We will also discuss the proposition based on the same method analyser for Prolog’s predicates. 1. Prolog Prolog is a logic programming language with its roots in automated theorem proving. Its terminology and concept are based on the first-order predicate logic. There are a few definitions required to understand the rules of programming in Prolog. Facts are used to describe some relations between the objects and they are always true. They consist of relation name, predicate and the list of comaseparated arguments enclosed with brackets. Each fact ends with full stop. For example, the fact expressing the relation of admiration and referring to two objects could have a form like(kate, flowers). Names of used object and predicates must start with lower case letters. The second type of statement in Prolog are rules. Rules comprise two parts, a head and a body connected with ‘:-‘ (neck symbol also read as ‘if’) and end with a full stop. Head is a name of the defined rule with the list of its arguments. Body is a set of goals separated with commas which state for logic ‘and’. That conditional form means that to satisfy the rule it is required for all its goals to succeed. While defining a rule it is allowed to use variables both in its head and body. A variable in Prolog is a string of letters, digits, and underscores beginning either with a capital letter or with an underscore. They are used to replace objects that can not be named at the moment. For example, if we want to describe a person who is a brother of somebody, in Prolog we would use the following form: brother(X,Y) :man(X), parents(O,M,X), parents(O,M,Y). E-mail address: [email protected] Pobrane z czasopisma Annales AIInformatica http://ai.annales.umcs.pl Data: 17/02/2017 10:30:27

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

XSB: Extending Prolog with Tabled Logic Programming

The paradigm of Tabled Logic Programming (TLP) is now supported by a number of Prolog systems, including XSB, YAP Prolog, B-Prolog, Mercury, ALS, and Ciao. The reasons for this are partly theoretical: tabling ensures termination and optimal known complexity for queries to a large class of programs. However the overriding reasons are practical. TLP allows sophisticated programs to be written con...

متن کامل

On Non-Termination in DCGs

Non-termination is a crucial problem when encoding unification-based grammar formalisms, although practical systems often diverge from their theoretical definitions. By termination we mean here finiteness of all possible logical derivations starting in the initial goal. Although from a theoretical point of view, we can claim it for decidable problems, often logical problems are confronted with ...

متن کامل

Inductive Mercury Programming

We investigate using the Mercury language to implement and design ILP algorithms, presenting our own ILP system IMP. Mercury provides faster execution than Prolog. Since Mercury is a purely declarative language, run-time assertion of induced clauses is prohibited. Instead IMP uses a problem-specific interpreter of ground representations of induced clauses. The interpreter is used both for cover...

متن کامل

Adding Constraint Solving to Mercury

The logic programming language Mercury is designed to support programming in the large. Programmer declarations in conjunction with powerful compile-time analysis and optimization allow Mercury programs to be very efficient. The original design of Mercury did not support constraint logic programming (CLP). This paper describes the extensions we added to Mercury to support CLP. Unlike similarly ...

متن کامل

Better Termination for Prolog with Constraints

Termination properties of actual Prolog systems with constraints are fragile and difficult to analyse. The lack of the occurs-check, moded and overloaded arithmetical evaluation via is/2 and the occasional nontermination of finite domain constraints are all sources for invalidating termination results obtained by current termination analysers that rely on idealized assumptions. In this paper, w...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Annales UMCS, Informatica

دوره 4  شماره 

صفحات  -

تاریخ انتشار 2006